import QtQuick 2.6
import QtQuick.Layouts 1.1

import "../../../../Base/UiBase"
import "../../../../Base/Config"
import Utils 1.0

Item {
    id:root

    property url fileUrl
    signal selected

    MouseArea {
        anchors.fill: parent
        onClicked: root.visible = false
    }
    Rectangle {
        width: 400 * Size.ratio
        height: menubar.height
        anchors.centerIn: parent

        MouseArea {
            // prevent clicking on the mask
            anchors.fill: parent
        }

        Column {
            id:menubar
            anchors {
                left: parent.left
                right: parent.right
                leftMargin: 25 * Size.ratio
                rightMargin: 25 * Size.ratio
            }
            spacing: 0

            Item {
                width: parent.width
                height: 80 * Size.ratio
                Text {
                    anchors.verticalCenter: parent.verticalCenter
                    text : qsTr("你的作品选择：")
                    font.pixelSize: Size.normalFont
                }

                BottomDivider{}
            }
            Item {
                width: parent.width
                height: 80 * Size.ratio
                Text {
                    anchors.verticalCenter: parent.verticalCenter
                    text : qsTr("录音");
                    font.pixelSize: Size.normalFont
                }

                MouseArea {
                    anchors.fill: parent
                    onClicked: {
                        picker.open()
                    }
                }
                BottomDivider{}
            }
            Item {
                width: parent.width
                height: 80 * Size.ratio
                Text {
                    anchors.verticalCenter: parent.verticalCenter
                    text : qsTr("相机")
                    font.pixelSize: Size.normalFont
                }

                MouseArea {
                    anchors.fill: parent
                    onClicked: {
                        root.destroy()
                    }
                }
                BottomDivider{}
            }
        }
    }

    AudioPicker {
        id:picker
        onAccepted: {
            root.fileUrl = fileUrl
            root.selected()
        }
    }
}
